package com.bupt.controller;

import com.bupt.bean.DeviceType;
import com.bupt.bean.DeviceTypeAttributeCheck;
import com.bupt.config.DeviceTypeAttributeCheckResult;
import com.bupt.config.DeviceTypeResult;
import com.bupt.config.Result;
import com.bupt.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value="报警参数接口",description="报警参数的增删改查、属性值类型")
@RestController
public class DeviceTypeAttributeCheckController {


    @Autowired
    private DeviceService deviceService;


    @ApiOperation("属性值类型")
    @GetMapping("/deviceTypeAttributeCheckPage/attributeValueType")
    public List deviceTypeAttributeCheckToAttributeValueType() {
        return deviceService.deviceTypeAttributeCheckToAttributeValueType();
    }

    @ApiOperation("根据设备类型ID查询报警参数")
    @GetMapping("/deviceTypeAttributeCheckPage/{deviceTypeId}")
    public List deviceTypeAttributeCheckPage(@PathVariable("deviceTypeId") Integer deviceTypeId) {
        return deviceService.findDeviceTypeAttributeCheckList(deviceTypeId);
    }

    @ApiOperation("添加报警参数")
    @PutMapping("/deviceTypeAttributeCheck/{deviceTypeId}")
    public DeviceTypeAttributeCheckResult addDeviceTypeAttributeCheck(@PathVariable("deviceTypeId") Integer deviceTypeId,@RequestBody DeviceTypeAttributeCheck deviceTypeAttributeCheck) {
        return deviceService.addDeviceTypeAttributeCheck(deviceTypeId,deviceTypeAttributeCheck);
    }


    @ApiOperation("通过ID修改报警参数")
    @PostMapping("/deviceTypeAttributeCheck/edit/{deviceTypeAttributeCheckId}")
    public DeviceTypeAttributeCheckResult editDeviceTypeAttributeCheck(@PathVariable("deviceTypeAttributeCheckId") Integer deviceTypeAttributeCheckId,@RequestBody DeviceTypeAttributeCheck deviceTypeAttributeCheck) {
        return deviceService.editDeviceTypeAttributeCheck(deviceTypeAttributeCheckId,deviceTypeAttributeCheck);
    }

    @ApiOperation("通过ID删除报警参数")
    @DeleteMapping("/deviceTypeAttributeCheck/deleteById/{deviceTypeAttributeCheckId}")
    public Result deleteDeviceTypeAttributeCheckById(@PathVariable("deviceTypeAttributeCheckId") Integer deviceTypeAttributeCheckId) {
        return deviceService.deleteDeviceTypeAttributeCheckById(deviceTypeAttributeCheckId);
    }
}
